Refactor code for AOP