fixed bugs, added logs