Final version with comments