ugly scala form logic, need to refactor now that I have it working