code updated for the new rules