various useful codes and routines