WIP - rewriting the code