functions for splitting a collection
function for handling exceptions with option type