almost finish the code