further refactoring and mini map!