added allocation function
fixed allocation
fixed again