Implemented InvalidRequestException instead of null checks.
Code cleanup.