Put file loading into a function