writing to temp and loading all at the end