bug fixes for helper functions