tweaked logic