added some exceptions and finished funcion invoke.