Refined the render code so that the wave is drawed correctly.