Add support for @sample keyword, factorize code