add form validation and fix csv generation