simplified code, better constraints