refactored some code for lightweigth struct