move get node logic to a func