solving several bugs