fixing cookbook code. Closes #531