Fixed _key[input] having an error

Since input is of Dynamic type, it can't be used directly for the
Map<Int, Bool> key. Added a check and a cast