porting client side tested code to server