removes not needed code and fills self.devices