cleaned up memory allocation