fixes errors logic