Simplify code

Kudos @sovainfo