Adding saftey to if statement