refactored get_task_by_id