Cleaned up some duplicated code