added iteration 6, comments and more readable code