guard against cast exceptions