adding algorithms code