fixed functionality of previous button