removing dead code
implementing pattern matching