moved check to prevent multiple submits