Cleaned up repeated code