Code clean, make "connection" argument of checkError function optional