got rid of heap memory allocation