fixed bugs in malloc implementation