small code cleanup, removing duplication of code