initializes prev to make code more robust