cleaning up repeated functionality