added checkIfUndefined