Wrap up page logic in a class and add validation