fixed heap overflow bug