Logic updated to Anton's way.