fixed isset logic statement to &&, also fixed json encoding