Removed code duplication
Reformated commit to align the patch