Changed plan matching to an array and a for loop