fix bugs in controllers and user model