cleaned up code formatting, still not perfect