added another function which handles the submit button. This is to help with readability.