Improve logic in backbone code