modified the code at pages controller