fixed some errors and integrity