error check method in controller