rewrote pages controller