cleaned up repetitive code