Extract Bluetooth into a class and refactor the code