changing code to use self.each