better organized c.c, added typedef and struct