add check for null and undefine stuff