fixed some bugs originating from previous 2 commits