Add Comments and imporved a bit of the code