WIP rewrite code for better be more configurable