simplifies the code, less code path fix minor issues that jshint and WebStorm found.