Adding checktype function for better type checking.