added some defensive programming
more defensvieness
mas defensive programming