Form is not working properly and page is crashing