fixes bugs on #5