Code simplification, removed duplication