refactor conways rules into separate function