refactor BSON decoder