better api code