restructure for easier to read code