added rotating, sliding window algorithm