Fixed mismatched parentheses bug

Fixed parentheses bug, minor tweaks to code to improve readability