classifier implementation, calculating distance from beginning ranker