abstracting some parts of code