match is done and bug-filled
fixed some bugs and might have caused conflicts