polished code thanks for previous one