correct graph function