refactored PUT method