functional version, properly selects node