fixing bugs/edge cases