added conditional to handle different pages