explained some functions in the lower part, about to move over some of my rationale