refactor and add input validation