attempting to refactor code