refactored the inverse