add error handling for position matching