Modified accuracy method, cleaned up code