Refactored script to use promises (just for fun)