Fixes: added checks for undefined values