reduced duplicate code