Made algorithm more specific