fix comparsions counting, fix median selection