Refactored script and added support for different profile