Commented code to make it more understandable