updated state selector so that it updates the map image. Cleaned up code.