fixed bug with last_error - close #549