migrate code into util directory