rewrite the 'strcut' function