refactoring as proposed by cba