parameter bugfix + shortened code by removing duplicate 'let' statements