added better enc key handling