Refactoring PUT handler