reorganize pygame code