combined two previous version... Works fine now.