added some bulletproofing