reorder input handling and frame generation so that an if can be removed