security refactoring