refactored code to show less warnings