Fix guard for controller and refactor models