Substring and strpos rewritten