Fixed tile check logic in tile write function