some useful utils code