Rewrote create.kpd function