Split code into smaller functions