get rid of redundant keys() calls