Refactor and Test