more re-organizing code