simplify the code
and fix backward compatibility

Signed-off-by: Antoine Villeret <antoine.villeret@gmail.com>