Logic to determine type
Logic to work