declared local imageObj var instead using global one