refactor, improve naming, and extracting functions
validating parameters