Move out handlers code to controllers