Fixed exempted elements bug. Improved code logic.