refactored the method to use dup instead of adding an empty array

please review and merge