refactored for readablility
more refactoring