added code from Kasper but can't make it work!!
it's commented out for now.