added max length checks