param validation and refactoring