logic sorted out