Validation on type forms and tidying of code