fixed memory allocation problem of struct. Must use sizeof structname instead of sizeof structname*