refactored form code to use new factory and data classes