finished core implementation. It works! But this definitely needs some refactoring stetps