Refactor code to manager class