moved controllers into directive code