a number of helper functions