refactored server-side implementation