I think that this deserve own function instead of writing spaghetti code.