Port to plain JS