check_program function

Validate and retrieve program IDs