Remove code duplication on embind