Are these sentences correct:

1-He did it in a way to attract attention.
2-He did it in a way not to attract attention.