simplify code
Merge pull request #314 from mhamrle/simplify_code2

simplify code 2