using 201 and 204 status codes and refactoring