make photoLoaded a named function to avoid creating many instances of it