speed improvement, replaced malloc with memset