fixed the remaining issues, now works correctly