refactor code wp