Better solution to checking if key exists.