fixed sag and added fallback for before-load