Dyanmic Algorithm first Pass