Move re-usable functions into separate script