cleaned up repeated code