Mweb 1043

@nandy-andy @RafLeszczynski @rogatty 
Extracting this logic to separate function might make the code more readable.