move SPA functions to a functions file