simplified code, fixed CS