Moved getter logic to its own function.