Extract form logic into its own class