fixed some bugs and modified some depreciated variables