Fixed memory misuse error