I think `loaded` should be set to true outside the if