almost finish the implementation