main controller code clean ing1