Added code to catch bad requests