Properly indented code and added a few comments