Implemented shuffling + minor refactoring