fixed undefined var. Added more detail