Added sorted insert for frontier.