refactor secure