fixed some codes, but still buggy.