Remove unecessary foreach loop