Refactor mdb