re-added check for valid data on submit that was removed during fixing issue 2 (this needs to be duplicated)