bugs fix for previous 3 commits