Refining the code