moved main logic to background script