begginings of controller