Added CakePHP verison
Moved logic to controller where it belongs