move smaller functions up
docs