refactor node to reduce repetition