implemented allocation and free functions