added logic for recovery - no testing yet