reorganising code