Added tolerance parameter to code.