Changed variable names and fixed a minor issue.