fixed some bugs from merging