Added a bit defensive coding