Cleaned up and renamed functions