removes unnecessary variables and keeps next always displayed while prev is hidden on first page