fixing some bugs and dois some adjustments