Update to make it more readable and improve comments