Added automatic recognition of input type