security  refactoring