Form validation and fixed bug