Made it more memory efficient