fix bugs in api