added check for undefined value