Refactored to use a framwork