use syscall wrappers

get rid of code duplication