moved server code out from runnable script