renamed variables for better comprehension
fixed issue

issue: creating temp variables for arrays