using proper handle scope and removing obsolete API