add check for undefined