refactoring Pine to be more generic