Cleaned up functions, both passed testing