Reorgnize api code