added Anil's check for type for edge cases