removed a bit of duplicate code