poppy code refactoring