1) loading params from buffer

2) refactored code