Something is working right now : There is a flaw on the edge cases i.e. when X & Y are 0 or Max_XY. I hope I can fix that tomorrow. Calling it a day. GN8