refactored form script