and cleanup code to load correct format