fixed leak. runs without error but final result varies