moved view logic to its own file