Refactored, added prune