Refactored to a more readable version, also added several verifications to ensure the entry has the desired structure.