Unfortunately, broken code, or asking about writing unwritten code is
strictly off-topic on Code Review. We would, however, like to review your
working code.
Assuming the current code is working, you should edit out the 'off-topic'ness of the question, so that it is not closed. —
Quill 6 secs ago