Fixed bug in code in update function
Small refactor in server