almost finished controller-gen