shouldn't you pass previous by reference here ?