refactored a couple of scripts into one with options