code update according to the feedback received from @aaronj1335