cleaned up the final code some