Correct Logic

Some changes and corrections