fixed bug in update
refactor in controller