Renaming and adding comments for understandability