reduce code complexity

Signed-off-by: Mattias Andrée <maandree@operamail.com>
reduce code complexity

Signed-off-by: Mattias Andrée <maandree@operamail.com>
reduce code complexity

Signed-off-by: Mattias Andrée <maandree@operamail.com>