Initial working, though hacky, script