changed code to fix bug and gave meaningful variable name and added
comments