Completed working script