fixed minor bug about hag declaration + code