Refactor s:add function