break block calculation logic into subroutines