Fixed memory error solution 3