Functions Logic Updated