reverted back to original algorithm