fixed pattern matching and added version check