refactored logic into more module from client controller