fixed excessive memory allocation