refactored but not working
fixed controller refactoring bug