added page end logic