rewrite all, more readable now