Implementing all the rules