added going back and forwards functionality