refining the SPA server sidee logic