cleaned and fixed bluetooth code