Refactored exercise view code