first bulk of code