added error handling for incorrect type declaration