add error handling to all system calls