implement some helper functions