Just for fun: removed some code repetitions...