Redundant code removed & Tests added