refactored, a little easier