null check added for error fixing