some defensive programming