added prev and next function