Refactor and improved design