added tolerance and iteration support