Finish implementation of error handling part1