moved checking for # to more sane position