I have a max utility function, therefore;
**U(x,y)= max(2x,y)**
and I am trying to find the demand function x = x(𝑝x , 𝑝y , 𝑀), note this function cannot be differentiated. I am familiar that the utility function states that it is best to have x=0 and all of the good y, or vice versa. So I've been trying to solve with the budget line making one x=0 and then again y=0 but I am unsure what to do from this point?

Working so far:
p1x+p2y=M
when y=0
x=m/p1

&
when x=0
y=m/p2

From this point, I am lost?
Thanks in advance