shorter, more general code