cleaning up repetitive code