note that this might be hard to debug and use a code block for the code.