Added previous page functionality, refactored source