small cleanup

- created and applied two utility functions (cleaner code, more minify-friendly):
  - `isFunction`
  - `isDefined`
- simplified some `if` checks