condensing code slightly