refactoring map and tiles