prelim nested kp support and casting using functions