Commented and improved readability