added null check etc.