Changed logic structure