Improved tile type assigning