greatly simplified code for abcd space generation