ugly hs implementation