todo: move attach to bundle and test all
working prototype, possibli buggy