added GetPreviousImagesBefore x function in db