main routines and methods