current scheme takes fifteen hours - needs refactoring