finally working with update now plus a little bit refactoring