api finished but need refactoring