SAFE refactor