refactored for minor cleanup