moved helper function outside
minor fixes
dynamically create AndLink when needed