refactored processNode operation,ProcessNode function for less code