fixed some errors and bugs...