fixed code to generate a proper sin wave