extract things into smaller functions