How to engineer the perfect cookie