Add function to invert maps