Added functionality to check for valid argument type. Refactored