refactored and added celery task support