changed .endswith with .match for regex support. code style fixes