Rewrite to make it not exceed PEP8 line limit