algorithm starting to look good