Cleaned up the code and started to handle form submit with location error handling