added more stuff to handle bad requests