cleaned up and fixed error