Refactor and simplification