Refactoring get_program method