by `!session_progress[level.id]` are you testing `session_progress.has_key?(level.id)` is it possible that it's present but false?