Refactored. Implementation of the current slide detection algorithm.