fixing undefined issue