Add comements and move code