shifted definition of loadBeforePhoto_cb so that it is defined before it is called