Have you been using Yann's? His method uses those sin/cos equations to locate
the neighbor to check, while mine will check based on set variables in the if/then loops you're talking about. They both do the same thing, but his is more graceful, and I really like how he did it. Mine is a very straightforward approach, but uses a lot of actions.
If you've been going off of his example, I would say to stick with his.
It sounds like you have been, so keep doing that! Mine was more intended for an example of one way to implement it and show it could be done, but I'm not a super wizard so it uses more events than it should. Then Yann made it into, in my view, a proper implementation for a game with more control over the generation and is overall a cleaner and efficient method. He did an awesome job making it better with his optimizations and I learned quite a bit from it, so thanks Yann!
Lastly, I put that disclaimer into mine because it's an example and not very efficient. More specifically, where you pointed out, it will create EVERY tile in the "lvl" array. This is fine when it's in a small scale, like how it is now you shouldn't get more than 7-8,000 tiles/objects in your layout. But if you go larger than that, like say to a terraria sized level, you're going to get tile counts to the millions. Just a small sized level in terraria is 4300x1200, or 5,160,000 potential tiles. You're not going to want to create all of those tiles, it'll bog and become unplayable. You'll want to implement some way to only have a set amount of tiles in your layout at once, such as what's going to be seen in your game window. I've got something already made that I can make an example from and show you if you want.
Best of luck with your game!