almost done with refactoring of backend