finished pocket algorithm