added building pattern regex logic