added another check for undefined stuff