Full commented Code