refactored, uses an obj