This piece of code is repeated several times, please create a separate function.