made minor changes to algo