elegant code with a minor misstake