A method for controlling a device