fixed 3 bugs