Added check for undefined