extracting common functions