Placed a function call outside a foreach statement since there's no need to call it more than once