migrate controllers to app/controllers
use jQuery each to ensure only run when ids are present