Cleaned up some DRY code