small fix
small syntax fixes
optimize pattern matching