Refactor, simplyfying code #371