Re-entrant javascript functions are working