PHP logic adjustement