Started on invalid input protection. Revision 5a