Modify main for devices control