code tidy up and use IS_LOADED