added more fixes for logical bugs