Revised for better versatility