add previous button if onPRev exists, clean up some logic to prevent useless dom elements