some useful codes, other people wrote