Extract format code removal to static method