restructure some angular controller