Code simplification, extern fixed

+ Fixed code duplicates