reorganize & tidy up for better readability (hopefully)