cleanup main
api logic