Explain step by step what the code does