these two expressions are repeated throughout the file. could you factor them out?