编辑以下句子，使其更具可读性和流畅性。

Ali spent two hours writing code, and he finally completed his programming project at 2am in the morning.
Ali completed his programming project at 2am after spending two hours writing code.