Added sub sample function