refactored so the clear function also clears the isLoaded flags