avoiding duplicate code