added Y1 function and improving Y2 implementation.