fixed memory free error
fixed return type