fix server code by putting delay afterwards