Initial value of prev doesn't actually matter but I still think 0 looks nicer and more correct.