Remove logic from controller and put into model
Add debugging statements

I know it's not nice, I leave it in for now, as I might need it again