added some precautions to changed api