first check if key exists before calling it in dict