fixed api logic