Working well, preparing for hierarchical algorithm