added parameters for dir and device id