function for that if statment. splitting up a bit