changed namings and added comments for better clarity