how does a compass work?