added conditionals to keys tasks