Working script - still needs some formatting