Confluence attachment history include deleted attachments too which cause the attachment version to not be a good criteria to find the last one.