Adding code to work as script