reorganising code layout (unfinished)