Script with the core functionality