Undefined object issue solved