seperate out controller code