fiex -dr to -rd in example
Added comments and refactored code