populating next right pointers