merging Shannon's code
merging Soe/Chun's code