small change to speed up bottom adjustment --- take a call to keys() outside of a loop