improved and commented almost all my code