use node-style callbacks and fix undefined logic