split api code off