refactored for better class structure