tweaked to fit the server side