merge code from bey6