Modify your UID fetch range to "*" or use SORT if supported:
uids, err := im.GetUIDs("50:*") // Fetch last 50 UIDs
or
uids, err := im.GetSortedUIDs("REVERSE DATE", 50) // If sorting is supported