updated inverse function