added error check routines to port + error