Move script into if