major change, now works perfect