Check error for calling procedure inside function