factorized code and add rake task for avatar resize