pointer issue fixed through correct casting