refactoring to make it graphite 0.9.11 compatible