Introducing scan algorithm