add Xpcall and update the environment