factor playlist length calculator into separate function.