Forms code refactored