cleaned up code & added functionality for PATCH