fix algorithm for finding newest