More repeating code into separate functions