preliminary offline working function