cleanup and getScore function