how to avoid losses in the market