added some "safety" measures