Refactor and merge