Added type checking when assigning return from function to a variable