added work with errors and fixed bugs