fix for separate files loading
add a check when calling callback function