Refactored duplicated code that was used for extracting properties from
an array into a trait