Fixed memory bug