refactoring zoo code