fixing some code duplication