re-implemented typed spawn