updated inexact routine to be more exact