re-organizing code