reorganize api controller
latest attempt to make api work