added form function to handle required fields