Changed algorithm
Eliminated a warning.