minor refactoring and using NODE_ENV