Maybe is worth to extract this to a function.