refactor code for resources module