api and some controller code