fixed the angle calculations
limiting the angle values