Fixed a logic error in tile construction