Refactor code in minimap