formState object added
refactoring functions