issue #1914, changing the place of equal_slices method and making code adaptable with PEP8 formatting