added an exception to catch NUllPointerException