Add checking for undefined