see #9 - fix a similar issue, extract a method