Code cleanup #2

modified player detection to be executed in a separate function