out of js and into controllers