Fixed variable on the wrong scope

Also removed unnecessary spaces.