Added required condition logic