null checks for ts and ks