added stdlib.h for malloc use