Changed algorithm used