Added NullPointerExcetion catch