Refactored some variables and added a useful comment