changed addition code to generic form so I can reuse it for other parts with variable size input.