Adding checkerror function