Changed logic version 2