Somehow it is working, huge refactoring needed