changed some PHP logic to be more streamlined
fixed PHP logic to be more streamlined