Refactoring radius code