malloc instead of returning local variables