fixed define inside procedure body bug