Move script to bottom. Organize code