Added code for inverse function