fixed oreo algorithm