refactoring code in receive_form