revamped serverside code