fix 'get declaration' logic