Removed a little repetition from the code

unminified:
326 sloc -> 174 sloc
11.719 kb -> 5.662 kb

minified:
7.022 kb -> 3.065 kb