added some saftey around the off function