more polished code