move handlefileloaded function