fixing three bugs