main functionality of backend implemented