Added a custom error handling for 409 response to respond with proper JSON message. Moved datastructure search into a seperate utility function.