Added if statement to avoid NullPointerException