fixing some bugs