Move form handler into factory