fixed issue with domains that dont start at 0. added a safety check for domain bounds