fixed the undefined issue