written some utility functions