Refactor SPL flow