Refactor control flow in master_controller and user_view