implementeing fragment decoding + refactoring