fixing bugs in previous commit