Added code for inverting larger matrices