fix bugs with typing while looking up; clean code