Added inverse function code and comments