Bugfix - incorrect parameter reference
Typo bug + minor refactoring