fixed typo and malloc size problem