validating function added
unified braces
corrected prefixes
better separation of tasks
unified formatting