rewrite, eve more standalone, more flexible