fix the 3 bugs