rewrite of HAL