bug fixing

judgement of keyLength is broken in boundary condition