fixed a leaked function