Fixed a scaling issue with slicing and simplified code