Formatted code and added navigation buttons