added infinity check