merged the conditions and ready for a parallel version