Replaced each with collect in few places