Updated to handle all three intended cases