When and how to invest in stock market