a lot of code magic