update functionality, refactored