corrected the place for mallocs