Fixed logic problem with last if statement.