made some code more efficient and got next prev file buttons working