fix apply pattern matching
flesh out given sample again