comments added
refactoring and basic validations.