Add maxval argument when using progressbar as a function.