pa5 simplified a bit of logic