Implemented new mod algorithm in runLnear()