replace switch with map