re-organize controller, ready to compile