Prevent IndexError when passing non-existent keys