reoganised code