Check key before pop'in to prevetn KeyError